import Vue from 'vue'
export default (function () {
  Vue.filter('menu_isShow', function (value) {
    let name
    if (value == 0) {
      name = '隐藏'
    } else {
      name = '显示'
    }
    return name
  })
  Vue.filter('submoneyf', function (m, p) {
    let name
    name = (parseFloat(m) + parseFloat(p)).toFixed(2)
    return name
  })

  Vue.filter('submoney', function (m, p) {
    let name
    name = (parseFloat(m) - parseFloat(p)).toFixed(2)
    return name
  })

  Vue.filter('balancemoney', function (m, n, t) {
    let sum
    if (t == '增加') {
      sum = (parseFloat(m) - parseFloat(n)).toFixed(2)
    } else {
      sum = (parseFloat(m) + parseFloat(n)).toFixed(2)
    }

    return sum
  })
  Vue.filter('ordermoney', function (m, n) {
    let sum
    sum = (parseFloat(m) - parseFloat(n)).toFixed(2)
    return Math.abs(sum).toFixed(2)
  })
  Vue.filter('adminLevel', function (v) {
    let name
    if (v == 0) {
      name = '超管'
    }
    return name
  })
  Vue.filter('adminStatus', function (v) {
    let name
    if (v == 1) {
      name = '启用'
    } else {
      name = '禁用'
    }
    return name
  })
  Vue.filter('brokerageModel', function (v) {
    let name
    if (v == 1) {
      name = '比例佣金'
    } else {
      name = '固定佣金'
    }
    return name
  })
  Vue.filter('changesStr', function (v) {
    let name
    if (v == '增加') {
      name = '+'
    } else {
      name = '-'
    }
    return name
  })
  Vue.filter('paidStatus', function (v) {
    let name
    switch (v.toString()) {
      case '0':
        name = '待处理'
        break
      case '1':
        name = '处理中'
        break
      case '2':
        name = '成功'
        break
      case '3':
        name = '失败'
        break
      case '4':
        name = '回退'
        break
    }
    return name
  })
  Vue.filter('tagColor', function (v) {
    let name
    switch (v.toString()) {
      case '0':
        name = 'warning'
        break
      case '1':
        name = 'default'
        break
      case '2':
        name = 'success'
        break
      case '3':
        name = 'error'
        break
      case '4':
        name = 'red'
        break
    }
    return name
  })
  Vue.filter('paidModels', function (v) {
    let name
    if (v == '0') {
      name = '商户模式'
    } else {
      name = '通道模式'
    }

    return name
  })
})()
